package teach.aistar.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import teach.aistar.model.entity.CarBrands;
import teach.aistar.model.entity.CarDetail;
import teach.aistar.model.entity.CarStyle;
import teach.aistar.model.entity.WebSeckill;
import teach.aistar.service.ICarBandsService;
import teach.aistar.service.ICarDetailService;
import teach.aistar.service.ICarStyleService;
import teach.aistar.service.IWebSeckillService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class WebSeckillController {

    @Autowired
    private IWebSeckillService iWebSeckillService;

    @Autowired
    private ICarDetailService iCarDetailService;

    @Autowired
    private ICarBandsService iCarBandsService;

    @Autowired
    private ICarStyleService iCarStyleService;

    @GetMapping("user/seckill")
    public String add(HttpServletRequest request, HttpSession session){
        List<WebSeckill> webSeckills = iWebSeckillService.selectWebSeckillAll();
        List<CarDetail> carDetails = iCarDetailService.selectAll();
        List<CarBrands> carBrands = iCarBandsService.selectAll();
        List<CarStyle> carStyles = iCarStyleService.findAll();
        request.setAttribute("carDetailsList",carDetails);
        request.setAttribute("webSeckillList",webSeckills);
        request.setAttribute("carBrandsList",carBrands);
        request.setAttribute("carStylesList",carStyles);
        return "seckill";
    }
}
